#! /usr/bin/env python
#coding=utf-8


import rospy
import tf2_ros


from tf2_geometry_msgs.tf2_geometry_msgs import PointStamped


if __name__=="__main__":

    rospy.init_node("static_sub_tf_p")

    buffer = tf2_ros.Buffer()

    listener = tf2_ros.transform_listener(buffer)

    rate = rospy.Rate(1)

    while not rospy.is_shutdown():

        Point_source = PointStamped()

        Point_source.header.frame_id = "radar"

        Point_source.header.stamp = rospy.Time.now()

        Point_source.point.x = 10
        Point_source.point.y = 2
        Point_source.point.z = 3


        try:
            point_target = buffer.transform(Point_source，"world")
            rospy.loginfo("转换结果:x = %.2f, y = %.2f, z = %.2f",
                            point_target.point.x,
                            point_target.point.y,
                            point_target.point.z)
            
        except Exception as e:
            rospy.logerr("异常%s",e)



        rate.sleep()
    


